import moment from 'moment'
Vue.prototype.moment = moment

import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'
// import enLang from 'element-ui/lib/locale/lang/en'// 如果使用中文语言包请默认支持，无需额外引入，请删除该依赖

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
// import httpRequest from '@/utils/httpRequest' // api: https://github.com/axios/axios
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import * as filters from './filters' // global filters

// 引入自定义工具
import { addDateRange, resetForm, selectDictLabel, getRouteParams, handleTree, handelTreeClone, getAge, getCurrentTimeType } from '@/utils/his-utils'
import { getDataByType } from '@/api/system/dict/data'

// 注册element
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
  // locale: enLang // 如果使用中文，无需设置，请删除
})

// 全局方法挂载
// Vue.prototype.$http = httpRequest // Ajax 请求方法
Vue.prototype.resetForm = resetForm // 通用重置表单
Vue.prototype.addDateRange = addDateRange // 通用添加时间参数
Vue.prototype.selectDictLabel = selectDictLabel // 通用参数翻译
Vue.prototype.getDataByType = getDataByType // 加载全局的根据字典类型查询字典的方法[基本每个页面都要使用]
Vue.prototype.getRouteParams = getRouteParams // 获取取路由路径上的参数
Vue.prototype.handleTree = handleTree // 加载全局构造菜单树
Vue.prototype.handelTreeClone = handelTreeClone // 加载全局构造菜单树
Vue.prototype.getAge = getAge // 根据生日判断年龄
Vue.prototype.getCurrentTimeType = getCurrentTimeType // 挂载全局计算 上午 下午 晚上
// 挂载全局消息框
Vue.prototype.msgSuccess = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'success' })
}
Vue.prototype.msgError = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'error' })
}
Vue.prototype.msgInfo = function(msg) {
  this.$message.info(msg)
}
Vue.prototype.msgWarning = function(msg) {
  this.$message({
    message: msg,
    type: 'warning'
  })
}
// notification通知
Vue.prototype.notSuccess = function(msg) {
  this.$notify({
    title: '成功',
    message: msg,
    type: 'success'
  })
}
Vue.prototype.notWarning = function(msg) {
  this.$notify({
    title: '警告',
    message: msg,
    type: 'warning'
  })
}
Vue.prototype.notInfo = function(msg) {
  this.$notify.info({
    title: '温馨提示',
    message: msg
  })
}
Vue.prototype.notError = function(msg) {
  this.$notify.error({
    title: '错误',
    message: msg
  })
}

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
